package com.ruoyi.dynamic.service.impl;


import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.dynamic.mapper.RoomUserPostPermissionMapper;
import com.ruoyi.dynamic.model.pojo.entity.RoomUserPostPermission;
import com.ruoyi.dynamic.service.IRoomUserPostPermissionService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 房间马甲设置 服务实现类
 * </p>
 *
 * @author Gnc
 * @since 2025-01-14
 */
@Service
public class RoomUserPostPermissionServiceImpl extends ServiceImpl<RoomUserPostPermissionMapper, RoomUserPostPermission> implements IRoomUserPostPermissionService {

    @Override
    public List<RoomUserPostPermission> getPerByUser(Long userPostId) {
        return lambdaQuery()
                .eq(RoomUserPostPermission::getUserPostId, userPostId)
                .list();
    }

    @Override
    public boolean isPermissionByRoomIdAndUserId(Long roomId, Long userId, Integer perId) {
        return lambdaQuery()
                .eq(RoomUserPostPermission::getRoomId, roomId)
                .eq(RoomUserPostPermission::getUserId, userId)
                .eq(RoomUserPostPermission::getPermissionId, perId)
                .count() > 0;
    }
}
